﻿using System;
using Castle.Windsor;
using RrslLite.Dsl;
using RrslLite.Net;
using RrslLite.Net.Contracts;
using RrslLite.Net.Messages;
using RrslLite.Net.Proxies;

namespace RrslLite.Configuration
{
    public class RrslLiteConfiguration
    {
        private static object locker = "locker";
        private static RrslLiteConfiguration instance = null;
        public static RrslLiteConfiguration Instance
        {
            get
            {
                if (instance == null)
                {
                    lock (locker)
                    {
                        instance = new RrslLiteConfiguration();
                    }
                }

                return instance;
            }
        }

        public virtual IWindsorContainer WindsorContainer { get; protected set; }
        public virtual BatchBuilderConfiguration BatchBuilderConfiguration { get; protected set; }

        public RrslLiteConfiguration()
        {
            lock(locker)
            {
                Init();
            }
        }

        protected virtual void Init()
        {
            WindsorContainer = new WindsorContainer();

            WithDefaultBatchBuilderConfiguration();
        }

        public virtual RrslLiteConfiguration WithIocContainer(IWindsorContainer windsorContainer)
        {
            WindsorContainer = windsorContainer;

            return this;
        }

        public virtual RrslLiteConfiguration WithDefaultBatchBuilderConfiguration()
        {
            BatchBuilderConfiguration = new BatchBuilderConfiguration();

            return this;
        }

    }
}
